using System;
using System.Collections.Generic;

namespace Shared.UI
{
    public static class UIDefine
    {
        public const string uiDir = "Assets/Res/Prefabs/UI";
        public const string uiPath = uiDir + "/" + "UI.prefab";
        
        public static List<UILayer> layers = new List<UILayer>()
        {
            new UILayer(LayerName.layerBackground, 0, "背景"),
            new UILayer(LayerName.layerBase, 50, "基础"),
            new UILayer(LayerName.layerModule, 100, "模块"),
            new UILayer(LayerName.layerPopup, 150, "弹出"),
            new UILayer(LayerName.layerFloat, 200, "浮动"),
            new UILayer(LayerName.layerUpper, 250, "上级"),
            new UILayer(LayerName.layerMiddleUpper, 300, "中上级"),
            new UILayer(LayerName.layerOverUpper, 350, "UI最上级"),
            new UILayer(LayerName.layerTopUpper, 400, "弹出最上级"),
            new UILayer(LayerName.layerCover, 450, "封面"),
            new UILayer(LayerName.layerNetCover, 500, "网络显示"),
        };

        public static Dictionary<Enum, UDefModel> defines = new Dictionary<Enum, UDefModel>()
        {
            { HotfixId.Hotfix, new UDefModel(HotfixId.Hotfix, UIType.Fixed, UINode.Top, LayerName.layerModule, UIId.None) },
            { UIId.Auth, new UDefModel(UIId.Auth, UIType.Fixed, UINode.Top, LayerName.layerBase, UIId.None) },
            { UIId.Connecting, new UDefModel(UIId.Connecting, UIType.Shared, UINode.Top, LayerName.layerNetCover, UIId.None) },
            { UIId.Login, new UDefModel(UIId.Login, UIType.None, UINode.Node, "Login", UIId.Auth) },
            { UIId.Notice, new UDefModel(UIId.Notice, UIType.Shared, UINode.Top, LayerName.layerPopup, UIId.None) },
            { UIId.Lobby, new UDefModel(UIId.Lobby, UIType.Fixed, UINode.Top, LayerName.layerBase, UIId.None) },
            { UIId.Loading, new (UIId.Loading, UIType.Shared, UINode.Top, LayerName.layerCover, UIId.None) },
            { UIId.CreateRole, new UDefModel(UIId.CreateRole, UIType.None, UINode.Node, "CreateRole", UIId.Auth) },
            { UIId.ServerList, new UDefModel(UIId.ServerList, UIType.None, UINode.Node, "ServerList", UIId.Auth) },
        };

        public static void Register(Enum id, UDefModel model)
        {
            if (model == null) return;

            if (defines.TryGetValue(id, out model))
                return;

            defines[id] = model;
        }
    }
}